﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MtApi;

namespace MTEA.LIB.Analysis
{
    public static class BollingAnalysis
    {
        public static bool isBollingOpen(this MtApiClient client, string symbol, int timeframes)
        {
            double tmp = double.MaxValue;
            for (int i = 1; i < 4; i++)
            {
                double duration = client.getBollingUpper(symbol, timeframes, i) -
                                  client.getBollingLower(symbol, timeframes, i);
                duration = Math.Abs(duration);

                if (tmp>duration)
                {
                    tmp = duration;
                    continue;
                }
                return false;
            }
            return true;
        }

        public static double getBollingUpper(this MtApiClient client,string symbol,int timeframes,int shift)
        {
            return client.iBands(symbol, timeframes, 20, 2, 0, 0, 1, shift);
        }
        public static double getBollingLower(this MtApiClient client, string symbol, int timeframes, int shift)
        {
            return client.iBands(symbol, timeframes, 20, 2, 0, 0, 2, shift);
        }

        public static double getBollingMain(this MtApiClient client, string symbol, int timeframes, int shift)
        {
            return client.iBands(symbol, timeframes, 20, 2, 0, 0, 0, shift);
        }


    }
}
